<template>
  <div>
    <table-ext :columns="columns" :searchForm="searchForm" :config="config" ref="tableExt">
    </table-ext>
  </div>
</template>
<script>
   import TableExt from '@/components/common/table-ext/table-ext.vue';
   import TableIcon from '@/components/common/table-ext/table-icon';
   export default {
    // 引入自定义表格组件
    components:{
      'table-ext': TableExt
    },
    data() {
      return {
        config:{ // 页面共通配置
          title: '询价单', //页面标题
          isPage: true, //是否分页
          isNo: true, //是否显示序号
          selection: true, //是否显示复选框
          crudMapping:{ // CRUD方法
            query:{
              url: this.lib.config.host.vendorDlv + "/vendormgt/dlv/dlvApply/query"
            },
            delete:{
              url: this.lib.config.host.vendorDlv + "/vendormgt/dlv/dlvApply/delete",
              text:'报价作废'
            },
          }
        },
        // 查询表单配置
        searchForm:[{
          label: '采购组织',
          key: 'orgId',
          type: 'select',
          dict: {
            url: this.lib.config.host.masterData + '/system/purOrgMgt/purOrg/getPurOrgByUserId/' + this.getCurrUserId(),
            method: 'get',
            label: 'purOrgName',
            value: 'id'
          }
        },{
          label: '采购组',
          key: 'groupId',
          type: 'select',
          dict: {
            url: this.lib.config.host.masterData + '/mdata/purOrgMgt/purGroup/getByPurOrgId/{orgId}',
            method: 'post',
            label: 'purGroupName',
            value: 'id'
          }
        },{
          label: '询价单号',
          key: 'enquiryNo',
          type: 'input'
        },{
          label: '询价主题',
          key: 'title',
          type: 'input'
        },{
          label: '询价员',
          key: 'publishUserName',
          type: 'input'
        },{
          label: '采购申请号',
          key: 'purReqNo',
          type: 'input'
        },{
          label: '询价方式',
          key: 'enquiryWay',
          type: 'select',
          dict: [{
            key: '1',
            value: '采购定价'
          }, {
            key: '2',
            value: '市场询价'
          }]          
        }],
        // 表格列定义
        columns:[{
          label: '操作', 
          width:'100',
          align:'center',
          render:(createElement, params)=>{ // 动态渲染，click事件示例
            if(params.row.submitStatus != 1){
              let _this = this;
              return createElement('div', {}, 
                [createElement('el-button', {
                    props: {
                      type: 'text',
                    },
                    on: {
                      click() {
                        _this.updateRow(params.row.id);
                      }
                    }
                  }, '编辑')
                ]);
              } else {
                return createElement('div', '--')
              }
          }},{
          label: '采购组织',
          key: 'purOrgName',
          width:'200',
          align:'center',
        },{
          label: '采购组',
          key: 'purGroupName',
          width:'200',
          align:'center',
        },{
          label: '品类',
          key: 'categoryName',
          align:'center',
          width:'200',
        },
        {
          label: '询价主题',
          key: 'title',
          align:'center',
          width:'220',
        },
        {
          label: '报价情况',
          key: 'quoteRate',
          align:'center',
        },{
          label: '询价方式',
          key: 'enquiryWay',
          align:'center',
        },{
          label: '询价员',
          key: 'publishUserName',
          align:'center',
        },{
          label: '发布日期',
          key: 'publishTime',
          align:'center',
        },{
          label: '报价截止时间',
          key: 'quoLimitTime',
          width:'120',
          align:'center',
        },{
          label: '采购申请号',
          key: 'purReqNo',
          align:'center',
          width:'120'
        },]
      };
    },
    methods: {
      // 新增或修改采购申请
      saveOrUpdateDlvApply() {
        this.$router.push('/Index/VendorDlv/SaveOrUpdateDlvApply');
      },
      //点击编码 跳转到视图页面
      updateRow(id) {
         this.$router.push('/Index/VendorDlv/SaveOrUpdateDlvApply?dlvApplyId='+ id);
      },
      //点击编码 跳转到视图页面
      toView(id) {
         window.open('/DlvApplyView?dlvApplyId='+ id)
      },
    }
  }
</script>